/**
 * author:Administrator
 * date:2016/3/16
 * desc:TODO
 */

"use strict";

let RawQuery = require('./_RawQuery.js');
class CagegoryQuery extends RawQuery {
  constructor() {
    super();
  }

  * findAll() {
    let sql = "select * from category";
    return yield this.query(sql);
  }

  * findRoot() {
    let sql = "select * from category where pid = 0";
    return yield this.query(sql);
  }

  * findChild(pid) {
    let sql = "select * from category where pid = '%pid'";
    sql = sql.replace('%pid', pid);
    return yield this.query(sql);
  }

}

module.exports = new CagegoryQuery();
